// pages/singleresult/singleresult.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    array:{
      name:"",
      address:"",
      pagesum:""
    },
    articles:[],
    areas:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    var index = options.index;
    // console.log(index);
    var preindex = options.preindex;
    // console.log(preindex);
    var no = options.no;
    // console.log(no);
    var preindexlis = preindex.split(":");
    var preindexname = preindexlis[0]+"="+preindexlis[1];
    var reurl = "http://localhost:8080/IB_web_war_exploded/servlet02?"+preindexname+"&no="+no;
    console.log(reurl);
    var indexlis = index.split("+");
    var name = indexlis[0];
    var address = indexlis[1];
    var pagesum = indexlis[2];
    that.setData({
      ["array.name"]:name,
      ["array.address"]:address,
      ["array.pagesum"]:pagesum
    });
    wx.request({
      url: reurl,
      data:{},
      method:'GET',
      header:{'Content-type':'application/x-www-form-urlencoded;'},
      success:function(res){
        var areas = res.cookies[0];
        areas = decodeURIComponent(areas);
        areas = areas.substring(6,areas.length-3);
        var areaslis = areas.split("&%@");
        var articles = res.cookies[1];
        articles = decodeURIComponent(articles);
        articles = articles.substring(9,articles.length-3);
        var articleslis = articles.split("&%@");
        // var collaborators = res.cookies[2];
        // collaborators = decodeURIComponent(collaborators);
        // collaborators = collaborators.substring(14,collaborators.length-3);
        // collis = collaborators.split("&%@");
        console.log(areas);
        console.log(articles);
        // console.log(collaborators);
        that.setData({
          articles:articleslis,
          areas:areaslis
        })
      },
      fail:function(res){
        console.log("请求失败！");
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})